package com.shop2cn.iapi.productsynces.testcase;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mongodb.BasicDBObject;
import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.productsynces.parameter.ESBean;
import com.shop2cn.iapi.productsynces.parameter.ESsearchBean;
import com.shop2cn.iapi.productsynces.service.ESCall;
import com.shop2cn.iapi.productsynces.service.ESGodsearchCall;
import com.shop2cn.iapi.productsynces.service.ESsearchCall;
import com.shop2cn.iapi.shenqisettlement.parameter.bean.GetCurrencyConfigBean;
import com.shop2cn.iapi.shenqisettlement.parameter.resp.GetCurrencyConfigResp;
import com.shop2cn.iapi.shenqisettlement.service.GetCurrencyConfigCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.AgentPriceDto;
import com.shop2cn.iapi.agentproducts.parameter.EditProductRebateBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.UpdateStockAndPriceBean;
import com.shop2cn.iapi.agentproducts.service.AddAgentProductCall;
import com.shop2cn.iapi.agentproducts.service.EditProductRebateCall;
import com.shop2cn.iapi.agentproducts.service.ImportAgentProductCall;
import com.shop2cn.iapi.agentproducts.service.ModifyAgentProductCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.listagentTypeBean;
import com.ymatou.iapi.godmch.service.listagentTypeCall;
import com.ymatou.iapi.godmch.service.removemchCall;
import com.ymatou.iapi.liveseller.parameter.ModifyLiveActivityBean;
import com.ymatou.iapi.liveseller.service.ModifyLiveActivityCall;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productsynces.parameter.es.EsGodProduct;
import com.ymatou.iapi.productsynces.parameter.es.EsProduct;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallService;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodfreightmgrService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.annotation.SqlMapperFactory;
import com.ymttest.database.annotation.product.IntergratedProductMapper;
import com.ymttest.database.model.GodProductActivityStock;
import com.ymttest.database.model.YmtCatalogs;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.model.YmtProducts;
import com.ymttest.database.model.YmtProductsI;
import com.ymttest.database.sqlwapper.GodProductActivityStockWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsWapper;
import com.ymttest.database.sqlwapper.YmtProductActivityStockWapper;
import com.ymttest.database.sqlwapper.YmtProductBrandWapper;
import com.ymttest.database.sqlwapper.YmtProductCategoryWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.database.sqlwapper.YmtProductsInActivityWapper;
import com.ymttest.database.sqlwapper.YmtProductsWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

public class Ts_ESsearch {
	
	private static ESBean esBean;
	private static ESCall escall;
	
	private static ESsearchBean bean;
	private static ESsearchCall call;
	private static ESGodsearchCall godCall;
	private static YmtCatalogsWapper ymtCatalogsWapper=new YmtCatalogsWapper();
	
	private static YmtProductActivityStockWapper productActStockWapper=new YmtProductActivityStockWapper();
	private static ModifyLiveActivityBean modifyliveactivityBean=new ModifyLiveActivityBean();
	private static ModifyLiveActivityCall modifyliveactivityCall=new ModifyLiveActivityCall();
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	private static int globalSellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));
	
	private static YmtCatalogsWapper catalogdWapper=new YmtCatalogsWapper();
	private static YmtProductsWapper ymtproductsWapper=new YmtProductsWapper();
	private YmtProductActivityStockWapper ymtProductActivityStockWapper=new YmtProductActivityStockWapper();
	private static YmtProductsInActivityWapper productInActivityWapper=new YmtProductsInActivityWapper();
	private static int sellerId3 = Integer.parseInt(EnvSetup.getData("SellerId"));//3383
	private  YmtProductsIWapper YmtProductsIWapper =new YmtProductsIWapper();
	private static IntergratedProductMapper ipm = SqlMapperFactory
            .getIntergratedProductMapper();
	
	private YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
	private YmtProductCategoryWapper ymtProductCategoryWapper=new YmtProductCategoryWapper();
	private YmtProductBrandWapper ymtProuductBrandWapper=new YmtProductBrandWapper();
	private ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
    private YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
	
	//渠道商
		private static int sellerId1 = AgentUsers.rootUserId;
		private static String sellerName1 = "NickautoTest";
		//代理商1
		private static int agentUserId1 = AgentUsers.agentUserId1;
		private static String agentUserName1 = "NickautoTest";
		//代理商2
		private static int agentUserId2 = AgentUsers.agentUserId2;
		private static String agentUserName2 = "NickautoTest";
		private static AddAgentProductCall addagentproductCall=new AddAgentProductCall();
		//渠道商->代理商1
		private static int mch_agentUserId1 = AgentUsers.agentUserId1;
		private static String mch_agentUserName1 = "NickautoTest";
		
		//vip渠道
		private static int vipRootUserId = AgentUsers.vipRootUserId;
		private static String vipRootUserName = "NickautoTest";
		//vip渠道->代理
		private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
		private static String vipAgentUserName1 = "dgsq408897016";
		//vip渠道->代理->代理
		private static int vipAgentUserId2 = AgentUsers.vipAgentUserId2;
		private static String vipAgentUserName2 = "NickautoTest";
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步ES");
	}
	
	@Before
	public void caseUp() {
		bean = new ESsearchBean();
		call = new ESsearchCall();	
		escall=new ESCall();
		esBean=new ESBean();
		godCall=new ESGodsearchCall();
	}
	
	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}
	
	@After
	public void caseDown() {
		Logger.end();
	}
	/**
	 * 校验代理商品
	 * @param product
	 * @param productId 1：若是渠道自采商品 productId指自采商品Id  2：若是代理商品 productId指代理商品Id
	 * @param productId2 如果是代理商品，二级分类来自 渠道自采商品  productId2是渠道自采商品Id
	 * @throws Exception
	 */
	private void checkverify_godProduct(EsGodProduct product,String productId,String... productId2) throws Exception
	{
		//ymt_product 与 es 比较
		AgentProductPo mainAgentProductPo=null;
		 YmtProductsI YmtProductsI =null;
		 YmtProductsI YmtAgentProductsI =null;
		 Integer userId=null;
		 String sProduct=null;
		 Date lastUpdate=new Date();
		 Integer status=0;//1:下架 2:上架
		 String title=null;
		 String remark=null;
		 String productParam=null;
		if(productId2.length>0)
		{
			 YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId2[0]).get(0);
			 YmtAgentProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
			 userId=YmtAgentProductsI.getiUserId();
			 sProduct=YmtAgentProductsI.getsProduct();
			 lastUpdate= YmtAgentProductsI.getdLastUpdate();
			 title=YmtAgentProductsI.getsProduct();
			 remark=YmtAgentProductsI.getRemark();
			 //issellout
			 check_godMainProduct_issellout(productId2[0],product);
		     mainAgentProductPo= YmtProductsIWapper.selectAgentProductByProductId(productId2[0]);   
		    
		}
		else
		{
			 YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
			 userId=YmtProductsI.getiUserId();
			 sProduct=YmtProductsI.getsProduct();
			 lastUpdate= YmtProductsI.getdLastUpdate();
			 title=YmtProductsI.getsProduct();
			 remark=YmtProductsI.getRemark();
			 //issellout
			 check_godMainProduct_issellout(productId,product);
	
		}
//		AgentProductPo agentProductPo=YmtProductsIWapper.selectAgentProductByProductId(productId);
//		productParam=agentProductPo.getProductParam();
		Logger.comment("remark:"+remark);
       //ymt_AgentProducts  与 es 比较
        AgentProductPo agentProductPo= YmtProductsIWapper.selectAgentProductByProductId(productId);
        productParam=agentProductPo.getProductParam().replace(":", " ").replace("{", "").replace("}", "").replace("'", "");
        Map category=null;
        Map category2=null;
        Map category3=null;
        if(YmtProductsI.getiCategoryId()!=0){
        //Ymt_ProductCategory 二级分类
         category= ymtProductCategoryWapper.getGodProductCategoryByCategoryId(YmtProductsI.getiCategoryId()).get(0);
        //一级分类
         category2= ymtProductCategoryWapper.getGodProductCategoryByCategoryId(Integer.parseInt(category.get("iMasterCategory").toString())).get(0);
        }
        if(YmtProductsI.getiThirdCategoryId()!=0){
        //三级分类
         category3= ymtProductCategoryWapper.getGodProductCategoryByCategoryId(YmtProductsI.getiThirdCategoryId()).get(0);
        }
        //品牌
        Map brand=null;
        if(YmtProductsI.getiBrandId()!=0)
          brand= ymtProuductBrandWapper.getProductBrandByBrandId(YmtProductsI.getiBrandId()).get(0);
        
		Logger.verifyEquals(product.getPid(), productId, "验证返回spid");
		
		Logger.verifyEquals(product.getSid(), userId, "验证返回Sid");
		
		//Logger.verifyEquals(product.gettitle(), sProduct, "验证返回sProduct");
		
        Logger.verifyEquals(product.getfcateid(), category==null?0:Integer.parseInt(category.get("iMasterCategory").toString()), "验证es返回一级分类Id  Ymt_ProductCategory.iCategoryId");
        Logger.verifyEquals(product.getScateid(), YmtProductsI.getiCategoryId(), "验证es返回二级分类Id  mt_Products.iCategoryId");
        Logger.verifyEquals(product.getTcateid(), YmtProductsI.getiThirdCategoryId(), "验证es返回三级分类Id  Ymt_Products.iThirdCategoryId");
       
        Logger.verifyEquals(agentProductPo.getAgentType(),product.getatype(), "验证传入的商品类型atype与es数据库是否一致(代理类型，0-自采，1-普通代理，2-VIP代理");
        
        Logger.verifyEquals(mainAgentProductPo!=null?mainAgentProductPo.getStatus():agentProductPo.getStatus(),product.getstatus(), "验证传入的商品类型status与es数据库是否一致代理商品状态（1-上架，2-下架）");
        //infop
		Logger.verifyEquals(product.getinfop(),agentProductPo.getInfoProgress(), "验证返回infop 为0,未改变(信息完善进度，-2-价格问题，-1-信息未完善，0，信息完整)");
	   //utime
	    SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Logger.verifyEquals(sdformat.format(product.getutime()),sdformat.format(agentProductPo.getUpdateTime()), "验证传入的商品LastUpdate与es数据库的utime是否一致Ymt_Products.dLastUpdate");
	   //stime
		Logger.verifyNotNull(product.getStime(), "验证返回的es数据库的Stime应用服务器当前时间 不为空");
	   //title title+一级分类+二级分类+三级分类+品牌中文+品牌英文
		//String titleString=title+(category2==null?" ":" "+category2.get("sCategory").toString())+(category==null?" ":" "+category.get("sCategory").toString())+(category3==null?" ":" "+category3.get("sCategory").toString())
		String subTitle=agentProductPo.getSubTitle()==null?"":" "+agentProductPo.getSubTitle();
		String titleStr=title+subTitle+(category3==null?" ":" "+category3.get("sCategory").toString())
		+(brand==null?" ":" "+brand.get("sBrand").toString())+(brand==null?" ":" "+brand.get("sBrandEn").toString())
		+(productParam!=null?(" "+productParam):"");
		Logger.comment("#####  titleString  ########## "+titleStr);
	    Logger.verifyEquals(titleStr.trim(),product.gettitle(), "验证传入的商品类型title与es数据库是否一致 title+一级分类+二级分类+三级分类+品牌中文+品牌英文");
	   
       //计算汇率
	   AgentProductPo agentProduct = ymtProductsIWapper.selectAgentProductByProductId(productId);
       GetCurrencyConfigBean getcurrencyconfigBean=new GetCurrencyConfigBean();
       GetCurrencyConfigCall getcurrencyconfigCall=new GetCurrencyConfigCall();
	   getcurrencyconfigBean.setCurrency(agentProduct.getCurrency());
	   getcurrencyconfigCall.setData(getcurrencyconfigBean);
	   getcurrencyconfigCall.callService();
	   GetCurrencyConfigResp currencyConfigResp = getcurrencyconfigCall
				.getCurrencyConfigResp();
	   //汇率
	   BigDecimal exchangeRmbRate=currencyConfigResp.getExchangeRmbRate();
	   //获取规格的最小价格
	   BigDecimal minPrice=BigDecimal.ZERO;
	   BigDecimal maxPrice=BigDecimal.ZERO;
	   BigDecimal rmbminp=BigDecimal.ZERO;
	   //查询规格列表
	   List<YmtCatalogs> clst =ymtCatalogsWapper.selectCatalogs(productId);
	   maxPrice=clst.stream().max((x,y)->Double.compare(Double.parseDouble(x.getFquoteprice().stripTrailingZeros().toPlainString())
			   ,Double.parseDouble(y.getFquoteprice().stripTrailingZeros().toPlainString()))).get().getFquoteprice();
	   
	   minPrice=clst.stream().min((x,y)->Double.compare(Double.parseDouble(x.getFquoteprice().stripTrailingZeros().toPlainString())
			   ,Double.parseDouble(y.getFquoteprice().stripTrailingZeros().toPlainString()))).get().getFquoteprice();
	   
	   rmbminp=minPrice.multiply(exchangeRmbRate).setScale(2, BigDecimal.ROUND_DOWN);
	   Logger.comment("###############exchangeRmbRate:"+exchangeRmbRate);
	   
	   Logger.verifyEquals(product.getrmbminp().stripTrailingZeros().toPlainString(), rmbminp.stripTrailingZeros().toPlainString(), "验证返回rmbminp");
	   Logger.verifyEquals(product.getminp().stripTrailingZeros().toPlainString(), minPrice.stripTrailingZeros().toPlainString(), "验证返回minPrice");
	   Logger.verifyEquals(product.getmaxp().stripTrailingZeros().toPlainString(), maxPrice.stripTrailingZeros().toPlainString(), "验证返回maxPrice");
	   //币种currency
	   Logger.verifyEquals(product.getCurrency(),agentProduct.getCurrency(), "验证返回Currency");
       //remark
	   Logger.verifyEquals(product.getRemark(),remark, "验证返回Remark");
	   //新增 20200506
	   Logger.verifyEquals(product.getIcs(), YmtProductsI.getiCatalogStatus(), "验证返回ics");
	   Logger.verifyEquals(product.getIba(), YmtProductsI.getiBondedArea(), "验证返回iba");
       //求出所有的规格库存 新增 20200506
	   List<YmtCatalogs> clst2 =ymtCatalogsWapper.selectCatalogs(productId2.length>0?productId2[0]:productId);
	   Integer inum=clst2.stream().mapToInt(a->a.getInum()).sum();
	   Logger.verifyEquals(inum,product.getStock(), "验证返回inum");
	   
	   Logger.comment("product.getIcs():"+product.getIcs());
	   Logger.comment("product.getIba():"+product.getIba());
	   Logger.comment("inum:"+inum);
	   
	   //新增 20200703 后面记得添加验证点 渠道商和代理
	  // Logger.verifyEquals(product.getPsid(), mainAgentProductPo!=null?mainAgentProductPo.getParentUserId():0, "验证返回ParentUserId");


	}
	/**
	 * 验证渠道商品是否售完
	 * @param productId
	 * @throws Exception
	 */
	private void  check_godMainProduct_issellout(String productId,EsGodProduct product) throws Exception
	{
		 //验证是否渠道售完
        int inum=0;//规格上的库存
        BasicDBObject search = new BasicDBObject();
		search.append("spid", productId);
		List<YmtCatalogs> clist =ymtCatalogsWapper.selectCatalogs(productId);
		for(int i=0;i<clist.size();i++)
		{
			inum += clist.get(i).getInum();
		}
		if(inum>0)
			Logger.verifyEquals(false, product.getissellout(), "验证es中的issellout是否售罄");
		else
			Logger.verifyEquals(true, product.getissellout(), "验证es中的issellout是否售罄");

	}

	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_009() {
		Logger.start(true,"同步ES-验证指令ProductStockChange,修改商品库存和价格");
		try{
			YmtCatalogsWapper catalogdWapper=new YmtCatalogsWapper();
				
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.verifyNotNull(productId, "响应报文-商品ID");

			Logger.comment("productID1:"+productId);
			
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			//修改 
			//ProductManagerCallServiceV2.updateProductStockNum(sellerId, productId, catalogs.getScatalogid(), 1);
			catalogs.setFquoteprice(new BigDecimal(500));
			catalogs.setInum(1);
			int count=catalogdWapper.updateByPrimaryKey(catalogs);

			esBean.setActivityId(0);
			esBean.setActionType("ProductStockChange");
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			//修改 20200628 修改价格
			Logger.verifyEquals(catalogs.getFquoteprice().stripTrailingZeros().toPlainString(),  new BigDecimal(product.getCatalogs().get(0).getPrice()).stripTrailingZeros().toPlainString(), "验证es的price");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_009_1() {
		Logger.start(true,"同步ES-验证指令ProductStockChange,修改神器商品库存和价格");
		try{
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			//addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			
			//修改 
			UpdateStockAndPriceBean UpdateStockAndPriceBean=AddAgentProductCallService.initUpdateStockAndPrice(sellerId1, catalogs.getSsku(), productId);
			UpdateStockAndPriceBean.setSalePrice(500d);
			//UpdateStockAndPriceBean.setVirtualStock(3);
			UpdateStockAndPriceBean.setRealStock(3);
			AddAgentProductCallService.UpdateStockAndPrice(UpdateStockAndPriceBean);
			
			catalogs=catalogdWapper.selectBySproductId(productId);
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ProductStockChange");
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
           // checkverify_godProduct(product,productId);
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			//修改 20200628 修改价格
			Logger.verifyEquals(500d, product.getCatalogs().get(0).getPrice(), "验证es的price");
			Logger.verifyEquals(500d, product.getminp(), "验证es的minp");
	
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_009_2() {
		Logger.start(true,"同步ES-验证指令ProductStockChange,修改神器商品库存和价格,第二次修改重新获取最小价格");
		try{
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			//addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			//修改 
			UpdateStockAndPriceBean UpdateStockAndPriceBean=AddAgentProductCallService.initUpdateStockAndPrice(sellerId1, catalogs.getSsku(), productId);
			UpdateStockAndPriceBean.setSalePrice(1000d);
			//UpdateStockAndPriceBean.setVirtualStock(3);
			UpdateStockAndPriceBean.setRealStock(4);
			AddAgentProductCallService.UpdateStockAndPrice(UpdateStockAndPriceBean);
			
			catalogs=catalogdWapper.selectBySproductId(productId);
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ProductStockChange");
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();

			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			EsGodProduct product=godCall.getEsProduct();
           // checkverify_godProduct(product,productId);
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			//修改 20200628 修改价格
			Logger.verifyEquals(1000d, product.getCatalogs().get(0).getPrice(), "验证es的price");
			Logger.verifyEquals(new BigDecimal(900), product.getminp(), "验证es的minp");
            
	
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_011() {
		Logger.start(true,"同步ES-验证指令ActivityStockChange,交易更新商品活动库存");
		try{
			Logger.comment("创建商品");
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Logger.comment("创建限购抢");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			
			AddactivityBean addactivityBean=AgentProductCallService.initProductaddactivity(sellerId1, productId, cids);
			AgentProductCallService.agentProductaddactivity(addactivityBean);
			
			GodProductActivityStock activityStock  = new GodProductActivityStockWapper().selectByProductId(productId);
			esBean.setActionType("ActivityStockChange");
			esBean.setActivityId(activityStock.getiProductInActivityId());//productInActivityId
			esBean.setProductId(productId);
			esBean.setCatalogId(activityStock.getsCatalogID());// 规格Id，目前用于交易（包括活动商品）更新库存
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			YmtProducts ymtProducts=ymtproductsWapper.selectProductByProductId(productId);

			//验证库存
			EsGodProduct esProduct=godCall.getEsProduct();
			Logger.verifyEquals(esProduct.getStock(), ymtProducts.getiTotalStock(), "验证es返回的库存");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_012() {
		Logger.start(true,"同步ES-验证指令CatalogStockChange,交易更新商品规格库存");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			
			int transactionId=TestDataManager.getRandomIntNum(9);
			int stockNum=TestDataManager.getRandomIntNum(1)+1;
			
			catalogs.setInum(stockNum);
			int count=catalogdWapper.updateByPrimaryKey(catalogs);
			
			Logger.comment("productId######:"+productId);
			Logger.comment("Scatalogid######:"+catalogs.getScatalogid());
			Logger.comment("stockNum######:"+stockNum);
			
			esBean.setActionType("CatalogStockChange");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());// 规格Id，目前用于交易（包括活动商品）更新库存
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_21() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品,不同步到productquery,同步到godproduct");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.getCatalogList().remove(0);
			addAgentProductBean.getCatalogList().get(0).setMarketPrice(200.3255);
			addAgentProductBean.setMarketCurrency("USD");
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(1000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();

			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			EsProduct esproduct = gson.fromJson(new JSONObject(call.getReturnData()).getJSONObject("hits").toString(),EsProduct.class);
		    Logger.verifyEquals(null,esproduct.getPid(),"验证es没有数据");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-渠道");
		try{
			
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			
		//	addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);

			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_1() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-普通代理");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			
		//	importAgentProductBean.getCatalogList().get(0).getDirectPrice();
			importAgentProductBean.setRemark("代理导入");
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			 
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();

			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_2() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-Vip渠道");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+productId);
			
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_3() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-Vip代理");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_4() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品,isshow是否显示在买家端-显示");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.getCatalogList().remove(0);
			addAgentProductBean.setInvisible(false);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Thread.sleep(5000);
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
			
            checkverify_godProduct(product,productId);
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_5() {
		Logger.start(false,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-渠道-分类、品牌为空");
		try{
			
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			//设置渠道-分类、品牌为空
        	addAgentProductBean.setCategoryId(0);
			addAgentProductBean.setThirdCategoryId(0);
			addAgentProductBean.setBrandId(0);
			
			addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_21_6() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品,不同步到productquery,同步到godproduct-不快递配送、自提");
		try{
			//开启运营
		    GodfreightmgrService.setCollectionGoodsByAdminCall(sellerId1, true);
		    //开启自提
            GodfreightmgrService.setCollectionGoodsBySellerCall(sellerId1, true);
            
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.getCatalogList().remove(0);
			
			addAgentProductBean.setExpressDelivery(false);//不快递配送
			addAgentProductBean.setCollectionGoods(true);//自提
			
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Thread.sleep(5000);
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			EsGodProduct product=godCall.getEsProduct();
            //checkverify_godProduct(product,productId);
            Logger.verifyEquals(addAgentProductBean.getCollectionGoods(), product.getColgoods(), "验证es的colgoods");
            Logger.verifyEquals(addAgentProductBean.getExpressDelivery(), product.getexpdel(), "验证es的expdel");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_21_7() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品,不同步到productquery,同步到godproduct-快递配送、不自提");
		try{
			//开启运营
		    GodfreightmgrService.setCollectionGoodsByAdminCall(sellerId1, true);
		    //开启自提
            GodfreightmgrService.setCollectionGoodsBySellerCall(sellerId1, true);
            
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.getCatalogList().remove(0);
			//新增
			addAgentProductBean.setExpressDelivery(false);//不快递配送
			addAgentProductBean.setCollectionGoods(true);//自提
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			modifyAgentProductBean.setExpressDelivery(true);//快递配送
			modifyAgentProductBean.setCollectionGoods(false);//不自提
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();

			Thread.sleep(5000);
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			EsGodProduct product=godCall.getEsProduct();
            //checkverify_godProduct(product,productId);
            Logger.verifyEquals(modifyAgentProductBean.getCollectionGoods(), product.getColgoods(), "验证es的colgoods");
            Logger.verifyEquals(modifyAgentProductBean.getExpressDelivery(), product.getexpdel(), "验证es的expdel");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_8() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-渠道-商品条码");
		try{
			
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			
			//新增 20200522
			List<String> barCodes = Arrays.asList("A123_b123_"+TestDataManager.getRandomNum(10),"A123_b123_"+TestDataManager.getRandomNum(10));
            addAgentProductBean.getCatalogList().get(0).setBarcode(barCodes.get(0));
            
		//	addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
		
			// 验证规格 商品条码
            Logger.verifyEquals(addAgentProductBean.getCatalogList().get(0).getBarcode(),product.getCatalogs().get(1).getBc(),"验证bc 渠道原始规格Id");

		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//业务测试反馈这个商家铺了大量商品导致总线阻塞
	public void Tc_ESsearch_22_9() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品,不同步到productquery,同步到godproduct-商品参数json新增2020617");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			sellerId1=501217421;
			agentUserId1=501217422;
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);

			//新增2020617
			String productParam="{'啊啊':'哈哈'}";
			addAgentProductBean.setProductParam(productParam);
			
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			
			importAgentProductBean.setRemark("代理导入");
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();

			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
        //	Logger.verifyEquals(product.getP aram(),addAgentProductBean.getProductParam().replace(":", " ").replace("{", "").replace("}", "").replace("'", ""), "验证返回ProductParam");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_10__111111111() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-普通代理-上级售价-上级售价");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			
		//	importAgentProductBean.getCatalogList().get(0).getDirectPrice();
			importAgentProductBean.setRemark("代理导入");
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			 
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();

			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_22_11_1111111111() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-渠道-上级售价");
		try{
			
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			
		//	addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);

			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_12() {
		Logger.start(true,"同步ES-验证指令AddAgentProduct,创建自采商品,导入代理商品-渠道");
		try{
			
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.setSubTitle("商品副标题_"+TestDataManager.getRandomIntNum(5));
		//	addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			esBean.setActivityId(0);
			esBean.setActionType("AddAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);

			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-渠道");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//修改参数
			modifyAgentProductBean.setInvisible(false);
			modifyAgentProductBean.setRemark("修改备注");
			modifyAgentProductBean.setThirdCategoryId(1004);
			
			modifyAgentProductBean.setCatalogStatus(100);
			modifyAgentProductBean.getCatalogList().get(0).setStock(25);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_1() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-普通代理");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBeanByImportant(agentProductId,importAgentProductBean);
			modifyAgentProductBean.setInvisible(false);
			modifyAgentProductBean.setRemark("代理修改");
			
			modifyAgentProductBean.setCatalogStatus(100);
			modifyAgentProductBean.getCatalogList().get(0).setStock(25);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();			
			Logger.comment("#######ProductId:###########"+agentProductId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_1_1() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,修改渠道商品库存-代理商品 跟着同步");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			modifyAgentProductBean.setInvisible(false);
			modifyAgentProductBean.setRemark("代理修改");
			
			modifyAgentProductBean.setCatalogStatus(100);
			modifyAgentProductBean.getCatalogList().get(0).setStock(25);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();			
			Logger.comment("#######ProductId:###########"+agentProductId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_2() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,vip渠道");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			//addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//修改参数
			modifyAgentProductBean.setInvisible(true);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getisshow(), false, "验证返回isshow");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_3() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-Vip代理");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBeanByImportant(agentProductId,importAgentProductBean);
			//修改参数
			modifyAgentProductBean.setInvisible(true);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getisshow(), false, "验证返回isshow");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_4() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-渠道-分类、品牌为空");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//修改参数
			
			modifyAgentProductBean.setCategoryId(0);
			modifyAgentProductBean.setThirdCategoryId(0);
			modifyAgentProductBean.setBrandId(0);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getfcateid(), 1368, "验证返回fcateid 其他分类");
            Logger.verifyEquals(product.getTcateid(), 1370, "验证返回Tcateid 其他分类 ");
            Logger.verifyEquals(product.getScateid(), 1369, "验证返回Scateid其他分类");
            Logger.verifyEquals(product.getbid(), 0, "验证返回bid");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_5() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品-币种,导入代理商品-渠道");
		try{
			//新增20200109 summing es新增币种
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//修改参数
		//	modifyAgentProductBean.setInvisible(false);
			modifyAgentProductBean.setCurrency("CNY");
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
            Logger.verifyEquals(product.getCurrency(),modifyAgentProductBean.getCurrency(), "验证返回Currency");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_6() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-渠道-商品条码");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
			//新增 20200522
			List<String> barCodes = Arrays.asList("A123_b123_"+TestDataManager.getRandomNum(10),"A123_b123_"+TestDataManager.getRandomNum(10));
            addAgentProductBean.getCatalogList().get(0).setBarcode(barCodes.get(0));
            
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//修改参数
			//新增 20200522
			barCodes = Arrays.asList("A456_b456_"+TestDataManager.getRandomNum(10),"A123_b123_"+TestDataManager.getRandomNum(10));
			modifyAgentProductBean.getCatalogList().get(0).setBarcode(barCodes.get(0));
            
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
			// 验证规格 商品条码
            Logger.verifyEquals(modifyAgentProductBean.getCatalogList().get(0).getBarcode(),product.getCatalogs().get(0).getBc(),"验证bc 渠道原始规格Id");
            
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_7_111111() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-渠道(20200703上级售价,不同步)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//修改参数
			modifyAgentProductBean.setInvisible(false);
			modifyAgentProductBean.setRemark("修改备注");
			modifyAgentProductBean.setThirdCategoryId(1004);
			
			modifyAgentProductBean.setCatalogStatus(100);
			modifyAgentProductBean.getCatalogList().get(0).setStock(25);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Logger.comment("#######ProductId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_23_8_111111() {
		Logger.start(true,"同步ES-验证指令ModifyAgentProduct,修改自采商品,导入代理商品-普通代理(20200703上级售价)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			//20200703 修改上级售价
			modifyAgentProductBean.getCatalogList().get(0).setDirectPrice(1500);
			modifyAgentProductBean.setInvisible(false);
			modifyAgentProductBean.setRemark("代理修改");
			
			modifyAgentProductBean.setCatalogStatus(100);
			modifyAgentProductBean.getCatalogList().get(0).setStock(25);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();			
			Logger.comment("#######ProductId:###########"+agentProductId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_24() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelf,渠道商上架商品-渠道,保存下架，然后再调用下架接口");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.setSaleType(2);//保存下架
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			Thread.sleep(5000);
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//上架
			AddAgentProductCallService.SetOnshelf(productId,sellerId1);
			
			Thread.sleep(5000);
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1未上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_24_1() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelf,渠道商上架商品-普通代理(代理不能导入进来的商品 下架)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.setSaleType(2);//保存下架
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//上架
			AddAgentProductCallService.SetOnshelf(agentProductId,agentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1未上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_24_2() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelf,渠道商上架商品-Vip渠道");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			addAgentProductBean.setSaleType(2);//保存下架
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//上架
			AddAgentProductCallService.SetOnshelf(productId,vipRootUserId);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1未上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_24_3() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelf,渠道商上架商品-Vip代理");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			addAgentProductBean.setSaleType(2);//下架
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//上架
			AddAgentProductCallService.SetOnshelf(agentProductId,vipAgentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelf");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1未上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_25() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelfSingle,商品上架，查找子商品依次发送上架指令-渠道(没有子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.setSaleType(2);//保存下架
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			Thread.sleep(10000);
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//上架
			AddAgentProductCallService.SetOnshelf(productId,sellerId1);
			Thread.sleep(10000);
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelfSingle");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1未上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_25_1() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelfSingle,商品上架，查找子商品依次发送上架指令-普通代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.setSaleType(2);//保存下架
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//上架
			AddAgentProductCallService.SetOnshelf(productId,sellerId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelfSingle");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1 上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_25_2() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelfSingle,商品上架，查找子商品依次发送上架指令-vip代理(无子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			addAgentProductBean.setSaleType(2);//保存下架
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			//上架
			AddAgentProductCallService.SetOnshelf(productId,vipRootUserId);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelfSingle");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1 上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_25_3() {
		Logger.start(true,"同步ES-验证指令AgentProductOnShelfSingle,商品上架，查找子商品依次发送上架指令-vip代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			addAgentProductBean.setSaleType(2);//下架
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//上架
			AddAgentProductCallService.SetOnshelf(agentProductId,vipAgentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOnShelfSingle");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1 上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_36() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelf,商品上架，查找子商品依次发送上架指令-渠道");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			
			addAgentProductBean.setExpressDelivery(true);//不快递配送
			addAgentProductBean.setCollectionGoods(false);//不自提
			
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//下架
			AddAgentProductCallService.SetOffshelf(productId,sellerId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 2, "验证返回status=2 下架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_36_1() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelf,商品上架，查找子商品依次发送上架指令-普通代理(指有字商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.setSaleType(2);//保存下架
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//下架
			AddAgentProductCallService.SetOffshelf(productId,sellerId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelf");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getstatus(), 2, "验证返回status=2 下架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_36_2() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelf,渠道商上架商品-Vip渠道");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//上架
			AddAgentProductCallService.SetOffshelf(productId,vipRootUserId);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 2, "验证返回status=2 下架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_37() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelfSingle,商品上架，查找子商品依次发送上架指令-渠道(没有子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//下架
			AddAgentProductCallService.SetOffshelf(productId,sellerId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelfSingle");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 2, "验证返回status=2 下架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_37_1() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelfSingle,商品上架，查找子商品依次发送上架指令-普通代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//上架
			AddAgentProductCallService.SetOffshelf(productId,sellerId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelfSingle");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 2, "验证返回status=2 下架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_37_2() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelfSingle,商品上架，查找子商品依次发送上架指令-vip代理(无子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			addAgentProductBean.setSaleType(2);//保存下架
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			//上架
			AddAgentProductCallService.SetOffshelf(productId,vipRootUserId);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelfSingle");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getstatus(), 2, "验证返回status=2 下架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_37_3() {
		Logger.start(true,"同步ES-验证指令AgentProductOffShelfSingle,商品上架，查找子商品依次发送上架指令-vip代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			addAgentProductBean.setSaleType(2);//下架
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//上架
			AddAgentProductCallService.SetOffshelf(agentProductId,vipAgentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("AgentProductOffShelfSingle");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
            checkverify_godProduct(product,agentProductId,productId);
            Logger.verifyEquals(product.getstatus(), 1, "验证返回status=1 上架");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_38() {
		Logger.start(true,"同步ES-验证指令DeleteAgentProduct,上级商品删除，所有下级商品也需要删除,代理商移除商品-渠道(没有子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			AddAgentProductCallService.DeleteProduct(productId, sellerId1);
			Logger.comment("#######productId:###########"+productId);
			
			esBean.setActivityId(0);
			esBean.setActionType("DeleteAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_38_1() {
		Logger.start(true,"同步ES-验证指令DeleteAgentProduct,商品上架，查找子商品依次发送上架指令-普通代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//同步代理商品
			//AddAgentProduct_sync(productId);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//同步代理商品
			//AddAgentProduct_sync(agentProductId);
			
			//删除
			AddAgentProductCallService.DeleteProduct(agentProductId, agentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("DeleteAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_38_2() {
		Logger.start(true,"同步ES-验证指令DeleteAgentProduct,商品上架，查找子商品依次发送上架指令-vip代理(无子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			AddAgentProductCallService.DeleteProduct(productId, vipRootUserId);
			
			esBean.setActivityId(0);
			esBean.setActionType("DeleteAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_38_3() {
		Logger.start(true,"同步ES-验证指令DeleteAgentProduct,商品上架，查找子商品依次发送上架指令-vip代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			addAgentProductBean.setSaleType(2);//下架
			//同步商品
			//this.createProduct_sync(productId);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//同步商品
			//this.createProduct_sync(agentProductId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//删除
			AddAgentProductCallService.DeleteProduct(agentProductId, vipAgentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("DeleteAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_38_4() {
		Logger.start(true,"同步ES-验证指令DeleteAgentProduct,上级商品删除，所有下级商品也需要删除-渠道商品(有上级商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			//获取商品ID
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//同步代理商品
			AddAgentProduct_sync(productId);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//同步代理商品
			AddAgentProduct_sync(agentProductId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			AddAgentProductCallService.DeleteProduct(agentProductId, agentUserId1);
			
			esBean.setActivityId(0);
			esBean.setActionType("DeleteAgentProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_39() {
		Logger.start(true,"同步ES-验证指令SetAgentProductPriceSpot,修改商品价格，更改代理的等级导致价格不符合要求-渠道(没有子商品,这里的子商品是指代理商的商品)");
		try{
			//创建代理
			listagentTypeBean typeBean=GodmchManageCallService.InitlistgentTypeBean(sellerId1);
			listagentTypeCall typeCall=GodmchManageCallService.listgentTypeCall(typeBean);
			//org.junit.Assert.fail();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			if(addAgentProductBean.getCatalogList().get(0).getAgentPriceList().size()==0)
			{
		       List<AgentPriceDto> agentPriceDtos = new ArrayList<>();
		       AgentPriceDto priceDto=new AgentPriceDto();
		       priceDto.setAgentPrice(5);
		       priceDto.setAgentTypeId(typeCall.getAgentTypes().get(0).getAgentType());
		       addAgentProductBean.getCatalogList().get(0).setAgentPriceList(agentPriceDtos);
			}
//		        
//			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(5);//渠道商代理价
			addagentproductCall.setData(addAgentProductBean);                                
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			//获取代理类型
//			listagentTypeBean typeBean=GodmchManageCallService.InitlistgentTypeBean(sellerId1);
//			listagentTypeCall typeCall=GodmchManageCallService.listgentTypeCall(typeBean);
			List<AgentPriceDto> agentPriceList=new ArrayList();
			AgentPriceDto  priceDto=new AgentPriceDto();
			priceDto.setAgentTypeId(typeCall.getAgentTypes().get(0).getAgentType());
			priceDto.setAgentPrice(500);
			agentPriceList.add(priceDto);
			//修改代理价格	
			modifyAgentProductBean.getCatalogList().get(0).setAgentPriceList(agentPriceList);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			esBean.setActivityId(0);
			esBean.setActionType("SetAgentProductPriceSpot");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			EsGodProduct product=godCall.getEsProduct();  
			Logger.verifyEquals(product.getPid(), productId, "验证返回spid");
			Logger.verifyEquals(product.getinfop(), 0, "验证返回infop 为0,未改变(信息完善进度，-2-价格问题，-1-信息未完善，0，信息完整)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_39_1() {
		Logger.start(true,"同步ES-验证指令SetAgentProductPriceSpot,修改商品价格，更改代理的等级导致价格不符合要求-普通代理(有子商品,这里的子商品是指代理商的商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			//addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(500);//渠道商代理价
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//同步代理商品
			AddAgentProduct_sync(productId);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//同步代理商品
			AddAgentProduct_sync(agentProductId);
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//修改渠道商品 直销价
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(500);//代理价
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			esBean.setActivityId(0);
			esBean.setActionType("SetAgentProductPriceSpot");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			EsGodProduct product=godCall.getEsProduct();  
			Logger.verifyEquals(product.getPid(), agentProductId, "验证返回spid");
			Logger.verifyEquals(product.getinfop(), -2, "验证返回infop 为0,未改变(信息完善进度，-2-价格问题，-1-信息未完善，0，信息完整)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_39_2() {
		Logger.start(true,"同步ES-验证指令SetAgentProductPriceSpot,商品上架，查找子商品依次发送上架指令-vip代理(无子商品,这里的子商品是指代理商的商品)");
		try{
			//获取代理类型
			listagentTypeBean typeBean=GodmchManageCallService.InitlistgentTypeBean(sellerId1);
			listagentTypeCall typeCall=GodmchManageCallService.listgentTypeCall(typeBean);
			List<AgentPriceDto> agentPriceList=new ArrayList();
			AgentPriceDto  priceDto=new AgentPriceDto();
			priceDto.setAgentTypeId(typeCall.getAgentTypes().get(0).getAgentType());
			priceDto.setAgentPrice(1);
			agentPriceList.add(priceDto);
			
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			addAgentProductBean.setSaleType(2);//下架
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//修改渠道商品 直销价
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(500);//代理价
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			esBean.setActivityId(0);
			esBean.setActionType("SetAgentProductPriceSpot");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			EsGodProduct product=godCall.getEsProduct();  
			Logger.verifyEquals(product.getPid(), productId, "验证返回spid");
			Logger.verifyEquals(product.getinfop(), 0, "验证返回infop 为0,未改变(信息完善进度，-2-价格问题，-1-信息未完善，0，信息完整)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_40() {
		Logger.start(true,"同步ES-验证指令RemoveAgenter,移除代理商，删除此代理及下级代理所有的商品-渠道商品(有上级商品) 渠道-代理");
		try{
			//创建渠道和代理商户
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			
			createmchBean createmchbean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			List<createmchBean> mchBeanList=GodmchManageCallService.InitcreatemchBeanForAgent(userId_channl);
			createmchBean createBean_agent=mchBeanList.get(0);
			GodmchManageCallService.createmchCallForAgent(createBean_agent);
			int userId_agent=createBean_agent.getMchId();
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,usercreateBean1.getNickname(),true);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			//获取商品ID
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(userId_agent,createBean_agent.getNickName(),productId,userId_channl,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
            //移除商户
			removemchCall removemchcall=GodmchManageCallService.InitremovemchForAgent(userId_channl,userId_agent);
			
			Thread.sleep(5000);
			esBean.setActionType("RemoveAgenter");
			esBean.setActivityId(userId_agent);
			esBean.setProductId(String.valueOf(userId_channl));
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_40_1() {
		Logger.start(true,"同步ES-验证指令RemoveAgenter,移除代理商，删除此代理及下级代理所有的商品-渠道商品(有上级商品) vip渠道-vip代理-vip代理");
		try{
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			
			createmchBean createmchbean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);

			List<createmchBean> mchBeanList=GodmchManageCallService.InitcreatemchBeanForAgent(userId_channl);
			createmchBean createBean_agent=mchBeanList.get(0);
			GodmchManageCallService.createmchCallForAgent(createBean_agent);
			int userId_agent=createBean_agent.getMchId();
			//创建第二个代理，与渠道绑定
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,usercreateBean1.getNickname(),true);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			//获取商品ID
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(userId_agent,createBean_agent.getNickName(),productId,userId_channl,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
            //移除商户
			removemchCall removemchcall=GodmchManageCallService.InitremovemchForAgent(userId_channl,userId_agent);
			
			Thread.sleep(5000);
			esBean.setActionType("RemoveAgenter");
			esBean.setActivityId(userId_agent);
			esBean.setProductId(String.valueOf(userId_channl));
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_41() {
		Logger.start(true,"同步ES-验证指令SyncAllAgentProductStockStatus-未售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAllAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(false,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
			
		   //新增 20200506
			YmtProductsI YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
		   Logger.verifyEquals(product.getIcs(), YmtProductsI.getiCatalogStatus(), "验证返回ics");
		   Logger.verifyEquals(product.getIba(), YmtProductsI.getiBondedArea(), "验证返回iba");
		   List<YmtCatalogs> clst2 =ymtCatalogsWapper.selectCatalogs(productId);
		   Integer inum=clst2.stream().mapToInt(a->a.getInum()).sum();
		   Logger.verifyEquals(inum,product.getStock(), "验证返回inum");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_41_1() {
		Logger.start(true,"同步ES-验证指令SyncAllAgentProductStockStatus-所有规格售完，同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAllAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(true,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(true,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		   //新增 20200506
			YmtProductsI YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
		   Logger.verifyEquals(product.getIcs(), YmtProductsI.getiCatalogStatus(), "验证返回ics");
		   Logger.verifyEquals(product.getIba(), YmtProductsI.getiBondedArea(), "验证返回iba");
		   List<YmtCatalogs> clst2 =ymtCatalogsWapper.selectCatalogs(productId);
		   Integer inum=clst2.stream().mapToInt(a->a.getInum()).sum();
		   Logger.verifyEquals(inum,product.getStock(), "验证返回inum");
			   
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_41_2() {
		Logger.start(true,"同步ES-验证指令SyncAllAgentProductStockStatus-单规格售完，不同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			//modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAllAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(false,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_41_3() {
		Logger.start(true,"同步ES-验证指令SyncAllAgentProductStockStatus-代理渠道商品部分规格-代理商品售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importAgentProductBean.getCatalogList().remove(0);//移除一个规格，代理渠道商品一个规格
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

//			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
		//	ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBeanByImportant(agentProductId, importAgentProductBean);
			
			//modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAllAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(true,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_43() {
		Logger.start(true,"同步ES-验证指令SyncAgentProductStockStatus,-直接同步库存状态,渠道商品,所有规格售完，同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(true,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			
//			//验证代理商品
//			bean.setProductId("pid:"+agentProductId);
//			godCall.setData(bean);
//			godCall.callService();
//			EsGodProduct agentProduct=godCall.getEsProduct();
//			Logger.verifyEquals(true,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_43_1_1() {
		Logger.start(true,"同步ES-验证指令SyncAgentProductStockStatus,-直接同步库存状态,代理商品,所有规格售完，同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
//			bean.setProductId("pid:"+productId);
//			godCall.setData(bean);
//			godCall.callService();
//			//验证渠道商品
//			EsGodProduct product=godCall.getEsProduct();
//			Logger.verifyEquals(true,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(true,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_43_1() {
		Logger.start(true,"同步ES-验证指令SyncAgentProductStockStatus,-直接同步库存状态,单规格售完，不同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			//modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(false,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_43_2() {
		Logger.start(true,"同步ES-验证指令SyncAgentProductStockStatus,-直接同步库存状态,代理渠道商品部分规格");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importAgentProductBean.getCatalogList().remove(0);//移除一个规格，代理渠道商品一个规格
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			//modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(false,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_42() {
		Logger.start(true,"同步ES-验证指令SyncBatchAgentProductStockStatus-未售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncBatchAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			esBean.setExtParam("[\""+agentProductId+"\"]");
			escall.setData(esBean);
			escall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			Thread.sleep(10000);
			//查询es
			
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(false,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_42_1() {
		Logger.start(true,"同步ES-验证指令SyncBatchAgentProductStockStatus-所有规格售完，同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncBatchAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			esBean.setExtParam("[\""+agentProductId+"\"]");
			escall.setData(esBean);
			escall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			Thread.sleep(10000);
			//查询es
			
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(true,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(true,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_42_2() {
		Logger.start(true,"同步ES-验证指令SyncBatchAgentProductStockStatus-单规格售完，不同步售完");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			//修改库存为0
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			modifyAgentProductBean.getCatalogList().get(0).setStock(0);
			//modifyAgentProductBean.getCatalogList().get(1).setStock(0);
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("SyncBatchAgentProductStockStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			esBean.setExtParam("[\""+agentProductId+"\"]");
			escall.setData(esBean);
			escall.callService();
			Logger.comment("#######productId:###########"+productId);
			Logger.comment("#######agentProductId:###########"+agentProductId);
			Thread.sleep(10000);
			//查询es
			
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			Logger.verifyEquals(false,product.getissellout(), "验证es渠道issellout(true:售完  false:未售完)");
			//验证代理商品
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct agentProduct=godCall.getEsProduct();
			Logger.verifyEquals(false,agentProduct.getissellout(), "验证es代理issellout(true:售完  false:未售完)");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_45() {
		Logger.start(true,"同步ES-验证指令PassiveModifyAgentProduct-修改所有子商品信息,修改自采商品,导入代理商品-渠道(没有子商品)");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
//			addAgentProductBean.setCategoryId(0);
//			addAgentProductBean.setThirdCategoryId(0);
//			addAgentProductBean.setBrandId(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
	
			Integer thirdCategoryId=1004;
			modifyAgentProductBean.setThirdCategoryId(thirdCategoryId);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("PassiveModifyAgentProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			esBean.setExtParam(productId);
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es渠道
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
		   //验证渠道商品
			EsGodProduct product=godCall.getEsProduct();

            checkverify_godProduct(product,productId);
			Logger.verifyEquals(thirdCategoryId,product.getTcateid(), "验证es渠道三级分类Id修改");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_45_1() {
		Logger.start(true,"同步ES-验证指令PassiveModifyAgentProduct-修改所有子商品信息,修改自采商品,导入代理商品-普通代理(有子商品)");
		try{
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			Thread.sleep(5000);
			//修改
			Integer thirdCategoryId=1004;
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			modifyAgentProductBean.setThirdCategoryId(1004);

			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Logger.comment("######### productId ######"+productId);
			Logger.comment("######### agentProductId ######"+agentProductId);

			
			Thread.sleep(8000);
			esBean.setActionType("PassiveModifyAgentProduct");
			esBean.setActivityId(0);
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			esBean.setExtParam(productId);
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es渠道
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
		   //验证渠道商品
			EsGodProduct product=godCall.getEsProduct();
			checkverify_godProduct(product,productId);
			Logger.verifyEquals(thirdCategoryId,product.getTcateid(), "验证es渠道三级分类Id修改");
			
			//查询es代理
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
		   //验证渠道商品
			EsGodProduct agentProduct=godCall.getEsProduct();
			checkverify_godProduct(agentProduct,agentProductId,productId);
			Logger.verifyEquals(thirdCategoryId,agentProduct.getTcateid(), "验证es代理三级分类Id修改");

            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_45_2() {
		Logger.start(true,"同步ES-验证指令PassiveModifyAgentProduct-修改所有子商品信息,修改自采商品,导入代理商品-渠道,分类和品牌为空");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addAgentProductBean.getCatalogList().remove(0);
//			addAgentProductBean.setCategoryId(0);
//			addAgentProductBean.setThirdCategoryId(0);
//			addAgentProductBean.setBrandId(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//修改
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);

			modifyAgentProductBean.setCategoryId(0);
			modifyAgentProductBean.setThirdCategoryId(0);
			modifyAgentProductBean.setBrandId(0);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			
			Thread.sleep(5000);
			esBean.setActionType("PassiveModifyAgentProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			esBean.setExtParam(productId);
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es渠道
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
		   //验证渠道商品
			EsGodProduct product=godCall.getEsProduct();

            checkverify_godProduct(product,productId);
            Logger.verifyEquals(product.getfcateid(), 1368, "验证返回fcateid 其他分类");
            Logger.verifyEquals(product.getTcateid(), 1370, "验证返回Tcateid 其他分类 ");
            Logger.verifyEquals(product.getScateid(), 1369, "验证返回Scateid其他分类");
            Logger.verifyEquals(product.getbid(), 0, "验证返回bid");
            
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_48() {
		Logger.start(true,"同步ES-验证指令ModifySingleAgentProductSellPrice,修改单个代理商品销售价,修改自采商品,导入代理商品-普通代理");
		try{
			//修改币种sqlserver不变，es改变
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			//修改
			//ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBeanByImportant(agentProductId,importAgentProductBean);
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			modifyAgentProductBean.setCurrency("CNY");
			//20200703 修改上级售价
			modifyAgentProductBean.getCatalogList().get(0).setDirectPrice(1500);
			
			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();			
			Logger.comment("#######ProductId:###########"+agentProductId);
			
			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));
			
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			
//			//验证es
			EsGodProduct product=godCall.getEsProduct();
			
//            checkverify_godProduct(product,agentProductId,productId);
//            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");
			
            //为什么金额和币种 验证要写固定，因为修改渠道商品币种，sql数据库中的代理商品币种没有更改，es中修改了，上面的公共方法算金额，是从数据库中查询的币种，然后查汇率算金额
		   Logger.verifyEquals(product.getrmbminp().stripTrailingZeros().toPlainString(),"6990.4", "验证返回rmbminp");
		   Logger.verifyEquals(product.getminp().stripTrailingZeros().toPlainString(), "6990.4", "验证返回minPrice");
		   Logger.verifyEquals(product.getmaxp().stripTrailingZeros().toPlainString(), "6990.4", "验证返回maxPrice");
		   //币种currency
		   Logger.verifyEquals(product.getCurrency(),"CNY", "验证返回Currency");

		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_052() {
		Logger.start(true,"同步ES-验证指令UpdateAgentProductRebate,商品分佣设置-同步分佣类型RebateType");
		try{
			int userId = 500945639;
			int AgentUserId = 500945640;
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			EsGodProduct product;
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			product = godCall.getEsProduct();
			Logger.verifyEquals(product.getRebateType(), -1, "验证es返回的getRebateType");
			EditProductRebateBean editproductrebateBean=new EditProductRebateBean();
			EditProductRebateCall editproductrebateCall=new EditProductRebateCall();
			editproductrebateBean = AddAgentProductCallService.initEditProductRebateBean(productId, AgentUserId,userId,20);
			editproductrebateCall.setData(editproductrebateBean);
			editproductrebateCall.callService();
			
			//{"ActionType":"UpdateAgentProductRebate","ActivityId":0,"AppId":"agentproducts.iapi.ymatou.com","ProductId":"p4430248","SellerId":0,"TransactionId":22431562}
			esBean.setActivityId(0);
			esBean.setActionType("UpdateAgentProductRebate");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			 product = godCall.getEsProduct();
			Logger.verifyEquals(product.getRebateType(), editproductrebateBean.getRebateType(), "验证es返回的getRebateType");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	
	
	/**
	 * 创建自采商品
                 导入代理商品
	 * @param productId
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	 private void AddAgentProduct_sync(String productId) throws ClientProtocolException, IOException
	 {
		 esBean.setActionType("AddAgentProduct");
		 esBean.setActivityId(0);
		 esBean.setProductId(productId);
		 esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
		 escall.setData(esBean);
		 escall.callService();
	 }
}

